<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<!--Converted with LaTeX2HTML 98.1 release (February 19th, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->


<title>Count the Trees</title>
<meta name="description" content="Problem H: Count the Trees">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head><body bgcolor="#ffffff" lang="EN">

<h1><br clear="ALL"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">
Count the Trees</a>&nbsp;</font></b></td></tr></tbody></table></center>
</h1>
Another common social inability is known as ACM (Abnormally Compulsive Meditation).
This psychological disorder is somewhat common among programmers. It can be 
described
as the temporary (although frequent) loss of the faculty of speech when the whole 
power of
the brain is applied to something extremely interesting or challenging.

<p>
Juan is a very gifted programmer, and has a severe case of ACM (he even 
participated
in an ACM world championship a few months ago). Lately, his loved ones are worried 
about
him, because he has found a new exciting problem to exercise his intellectual 
powers, and he
has been speechless for several weeks now. The problem is the determination of 
the number
of different labeled binary trees that can be built using exactly <i>n</i> different
elements. 

</p><p>
For example, given one element <i>A</i>, just one binary tree can be formed
(using <i>A</i> as the root of the tree). With two elements, <i>A</i> and <i>B</i>, four
different binary trees can be created, as shown in the figure.

</p><p>
</p><div align="CENTER">
<br>
<img src="acm-10007_files/10007img1.gif" alt="\begin{picture}(400,90)(50,0)
\put(115,62){A}
\put(75,10){B}
\put(120,60){\vecto...
...}}
\put(365,62){B}
\put(405,10){A}
\put(370,60){\vector(1,-1){40}}
\end{picture}" border="0" height="96" width="538" align="BOTTOM">
<br></div>

<p>
If you are able to provide a solution for this problem, Juan will be able to 
talk again, and his
friends and family will be forever grateful.

</p><p>

</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">
Input</a>&nbsp;</font>
</h2> 
The input will consist of several input cases, one per
line. Each input case will be specified by the number <i>n</i> (
<i>1 &#8804; n &#8804; 300</i>
) of
different elements that must be used to form the trees. A number <tt>0</tt> will
mark the end of input and is not to be processed. 

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">
Output</a>&nbsp;</font>
</h2> 
For each input case print
the number of binary trees that can be built using the <i>n</i> elements, followed
by a newline character. 

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">
Sample Input</a>&nbsp;</font>
</h2>
<pre>1
2
10
25
0
</pre>

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001004000000000000000">
Sample Output</a>&nbsp;</font>
</h2>
<pre>1
4
60949324800
75414671852339208296275849248768000000
</pre>

<p>
<br></p><hr>
<address>
<i>Miguel Revilla</i>
<br><i>2000-08-21</i>
</address>
</body></html>